/**
 *
 * @param InfoId (string) pkid
 * @param Title (string) 企业名称
 * @param Time (string) 时间
 * import { getNowRoute } from '@/units'
 * const nowRoute = getNowRoute()
 * nowRoute.getRouter(data.data.pkid, data.data.enterpriseName)
 */

import { useRouter } from 'vue-router'
const getNowRoute = () => {
  const StorageModuleAnchorOpera = sessionStorage.getItem('ModuleAnchorOpera')
  if (!StorageModuleAnchorOpera) {
    return false
  }
  let ModuleAnchorOpera = JSON.parse(StorageModuleAnchorOpera)

  const router = useRouter()
  const getRouter = (InfoId, Title, Time) => {
    let nowRouter = router.currentRoute.value.path
    let PageUrl = ModuleAnchorOpera.PageUrl

    if (nowRouter === PageUrl) {
      ModuleAnchorOpera = {
        ...ModuleAnchorOpera,
        InfoId,
        Title,
        Time,
      }
      sessionStorage.setItem(
        'ModuleAnchorOpera',
        JSON.stringify(ModuleAnchorOpera)
      )
    }
  }
  return {
    getRouter,
  }
}

export { getNowRoute }
